<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>handling excptions</title>
</head>
<body>
	<?php 

		require('WriteToFile.php');
		@$data=$_POST['my_input'];
		try{

			$fp=new WriteToFile("data.txt");
			if(isset($data)){
			$fp->write($data);
			$fp->close();
			echo '<p> the data has been written.</p>';

			}
			else{

				echo '<p> plese input some word in this input box</p>';
			}
			
		}
		catch(Exception $e){

			echo '<p>the process could not be completed because the scripts:'.$e->getMessage().'<br>'.$e->getDetail().'</p>';
		}
		echo '<form action="write_to_file.php" method="post">
	 	<p>please input some words:</p>
	 	<input type="text" id="txt" name="my_input">
	 	<input type="submit" id="sub" name="my_sub" value="submit">
	 </form>';
	 ?>
	 
</body>
</html>